home *** CD-ROM | disk | FTP | other *** search
- Path: airdmhor.gen.nz!not-for-mail
- From: gumboot@airdmhor.gen.nz (Simon Hosie)
- Newsgroups: comp.lang.c
- Subject: Re: Determining the length of an int in string form
- Date: 20 Mar 1996 07:21:46 +1200
- Organization: Airdmhor : a couple of BBS's, a bunch of people, and a cat.
- Message-ID: <4in1ga$ogk@airdmhor.gen.nz>
- References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net>
- NNTP-Posting-Host: airdmhor.gen.nz
- X-Newsreader: TIN [version 1.2 PL2]
-
- wkaufman@wkaufman.us.oracle.com (William Kaufman) wrote:
- +In article <3146D058.DD7@cbm.com> Dave Payne <paynedc@cbm.com> writes:
- +] Consider this:
- +]
- +] I have a variable of type int, and I would like to use the sprintf()
- +] function to write this variable to a string. However, I want to
- +] dynamically allocate the space for the string, and only malloc enough
- +] space to hold the int.
-
- Doug & Rose Miller:
- > WHY ???
- > Even a 32-bit int is only 9 characters at most, and that's *with* the sign. Why not just declare
- > a string and be done with it? Is storage space that tight for you, that nine bytes matters?
-
- That's wrong straight off, 2 ^ 31 is 2147483648 which is 10 characters
- (unless you mean in hex), then there's another character for the sign. Then
- lots and lots more characters if the int is more than 32 bits.
-
-
- Darn it! That's my clock radio trying to wake me up - I'd better go to
- bed soon.
-